import { defineStore } from 'pinia'
import { ref } from 'vue'
import img01 from '@/static/img/1.png'
import img02 from '@/static/img/2.png'
import img03 from '@/static/img/3.png'
export const useCategory = defineStore('category', () => {
  const buyMethodActiveIndex = ref<number>(0 as number)

  const buyMethodList = ref([
    {
      name: '堂食',
      value: 0,
      imgUrl: img01,
    },
    {
      name: '外带',
      value: 1,
      imgUrl: img02,
    },
    {
      name: '配送',
      value: 2,
      imgUrl: img03,
    },
  ])
  const getBuyMethodList = () => {
    return buyMethodList.value
  }
  const getBuyMethodName = (val: number) => {
    return buyMethodList.value.find((item) => item.value === val)?.name || ''
  }
  const setBuyMethodActiveIndex = (val: number) => {
    buyMethodActiveIndex.value = val
  }
  const getBuyMethodActiveIndex = () => {
    return buyMethodActiveIndex.value
  }

  return {
    getBuyMethodList,
    getBuyMethodName,
    buyMethodActiveIndex,
    getBuyMethodActiveIndex,
    setBuyMethodActiveIndex,
  }
})
